package com.hbfec.mqttmanager.entity;

import com.alibaba.fastjson.annotation.JSONField;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;

public class UserEntity implements Serializable {
    private static final long serialVersionUID = 1L;
    private String username;
    @JSONField(serialize=false)
    private String password;
    private String salt;
    private boolean superuser;
    private Date created;

    public UserEntity() {
        super();
    }
    public UserEntity(String username, String password, String salt, boolean superuser, Date created) {
        super();
        this.password = password;
        this.username = username;
        this.salt = salt;
        this.superuser = superuser;
        this.created = created;
    }


    public String getUsername() {
        return username;
    }
    public void setUsername(String username) {
        this.username = username;
    }
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }

    public Date getCreated() {
        return created;
    }

    public void setCreated(Date created) {
        this.created = created;
    }

    public boolean isSuperuser() {
        return superuser;
    }

    public void setSuperuser(boolean superuser) {
        this.superuser = superuser;
    }

    public String getSalt() {
        return salt;
    }

    public void setSalt(String salt) {
        this.salt = salt;
    }

    @Override
    public String toString() {
        return String.format( "{username:%s, password:****, superuser:%b, created:%s}",
                username, superuser, new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(created));
    }
}
